﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.Domain;
using Kooboo.IoC;

namespace Kooboo.Commerce.Domain.Services
{
    class TaxService:ServiceBase<ITaxRepository,ITax>
    {
        //internal TaxService()
        //{
        //}

        public override IQueryable<ITax> QueryService
        {
            get {
                return this.Repository.Taxes;
            }
        }

       
        public void Post(ITax tax)
        {
            
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Post(tax);
                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Put(ITax tax)
        {
            
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                   
                    this.Repository.Put(tax);
                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Delete(ITax tax)
        {
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Delete(tax);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

  

    }

}
